﻿@model Core.Manage.User.FamerVWEntity
@using XStudio.Core.Ext
@using XStudio.Framework.Util
@using XStudio.WebFramework.Mvc.Extensions
<script type="text/javascript">
    var FamerInput = {};

    FamerInput.Save = function (e) {
        var frm = $(e).parents("form").first();
        if (!$(frm).valid())
            return;

        $.post($(frm).attr("action"), $(frm).serialize(), function (data) {
            if (data.IsOK) {
                //刷新列表
                $('#tbFamerList0').datagrid('reload');
                //关闭窗口
                $.closeWin(e);
            }
            else
                alert(data.Description);
        });
    };

    FamerInput.Back = function (e) {
        $.closeWin(e);
    };

    //页面加载
    $(function () {
        var v = $('#frmFamerInput').validate({
            rules: {
                Account: { required: true },
                Password: { required: true },
                NickName: { required: true },
                PhoneNo: { required: true },
                sexID: { required: true, min: 0 },
                cooID: { required: true, min: 0 }
            },
            messages: {
                Account: { required: "必须填" },
                Password: { required: "必须填" },
                NickName: { required: "必须填" },
                PhoneNo: { required: "必须填" },
                sexID: { required: "必须填", min: "请选择性别" },
                cooID: { required: "必须填", min: "请选择合作社" }
            }
        });
    });
</script>
<input type="hidden" name="IsEdit" id="IsEdit" value="@ViewBag.IsEdit" />
<form name="frmFamerInput" id="frmFamerInput" method=post action="@Url.Action(@ViewContext.RouteData.Values["Action"].ToString())">
    <table class="tbl-input" cellspacing="0" style="width: 100%">
        <colgroup>
            <col style="width: 100px;" />
            <col class="w5">
            <col />
        </colgroup>
        <tbody>
            @if (string.Equals(ViewContext.RouteData.Values["Action"].ToString(), "Edit", StringComparison.InvariantCultureIgnoreCase))
            {
                <tr>
                    <th>
                        帐号：
                    </th>
                    <td>
                        @Html.TextBoxFor(t => t.Account, new { disabled = "disabled", @readonly = "readonly", style = "width:200px", maxlength = 20 })
                    </td>
                    <td class="slight">
                        <span class="btn-infomust">必填项</span>
                    </td>
                </tr>
            }
            else
            {
                <tr>
                    <th>
                        帐号：
                    </th>
                    <td>
                        @Html.TextBoxFor(t => t.Account, new { style = "width:200px", maxlength = 20 })
                    </td>
                    <td class="slight">
                        <span class="btn-infomust">必填项</span>
                    </td>
                </tr>
            }

            <tr>
                <th>
                    密码：
                </th>
                <td>
                    @Html.TextBoxFor(t => t.Password, new { style = "width:200px", maxlength = 20 })
                </td>
                <td class="slight">
                    <span class="btn-infomust">必填项</span>
                </td>
            </tr>
            <tr>
                <th>
                    姓名：
                </th>
                <td>
                    @Html.TextBoxFor(t => t.NickName, new { style = "width:200px", maxlength = 20 })
                </td>
                <td class="slight">
                    <span class="btn-infomust">必填项</span>
                </td>
            </tr>
            <tr>
                <th>
                    手机号：
                </th>
                <td>
                    @Html.TextBoxFor(t => t.PhoneNo, new { style = "width:200px", maxlength = 20 })
                </td>
                <td class="slight">
                    <span class="btn-info">必填项</span>
                </td>
            </tr>
            <tr>
                <th>
                    性别：
                </th>
                <td>
                    @Html.ParameterRadioButtonList("sexID", 301100, Model.Gender.ToString())
                </td>
                <td class="slight">
                    <span class="btn-infomust">必选项</span>
                </td>
            </tr>
            <tr>
                <th>
                    家庭地址：
                </th>
                <td>
                    @Html.TextBoxFor(t => t.FamilyAddress, new { style = "width:200px", maxlength = 20 })
                </td>
                <td class="slight">
                    <span class="btn-info">必填项</span>
                </td>
            </tr>
            <tr>
                <th>
                    所属合作社：
                </th>
                <td>
                    @Html.DropDownList("cooID")
                </td>
                <td class="slight">
                    <span class="btn-infomust">必选项</span>
                </td>
            </tr>
            <tr>
                <td colspan="3" style="text-align: center;">
                    <p class="op">

                        <input type="button" id="btnSave" onclick="FamerInput.Save(this);" class="btn-8" value="保存" />
                        <input type="button" value="返回" onclick="FamerInput.Back(this);" class="btn-8" />
                    </p>
                </td>
            </tr>
        </tbody>
    </table>
</form>
